import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;


public class Player extends GameObject {
	private int health;
	private boolean right = false, left = false;
	
	public Player(int xPos, int yPos,
			int width, int hight, int health, int vx) {
		
		super(xPos, yPos, width, hight, vx, 0);
		this.health = health;
		this.rect = new Rectangle(xPos, yPos - 10, width + 2, height + 10);
	}

	@Override
	public void update(Main screen) {
		if(health == 0) {
			return;
		}

		if(isLeft() && (xPos > 1)) {
			xPos -= vx;
		}
		else if(isRight() && (xPos < (screen.getWidth() - width - 1))) {
			xPos += vx;
		}
		
		rect.x = xPos;
	}

	@Override
	public void render(Graphics g, Main screen) {
		update(screen);
		g.setColor(new Color(125, 255, 120)); //some like green
		g.fillRect(xPos, yPos, width, height);
	}

	public int getHealth() {
		return health;
	}

	public void setHealth(int health) {
		this.health = health;
	}

	public boolean isRight() {
		return right;
	}

	public void setRight(boolean right) {
		this.right = right;
	}

	public boolean isLeft() {
		return left;
	}

	public void setLeft(boolean left) {
		this.left = left;
	}

}
